<?php
/*********************/
/*                   */
/*  前台文章列表制     */
/*   BY voiet        */
/*   2009-7-30       */
/*                   */
/*********************/

class cct_artlist extends ctl_artlist
{
	function index( $cat_id, $page = 1 )
	{
		$this->id = array(
			"node_id" => $cat_id
		);
		if ( intval( $cat_id ) )
		{
			$objSitemap = $this->system->loadmodel( "content/sitemap" );
			$filter['node_id'] = intval( $cat_id );
			if($filter['node_id'] !=100 && $filter['node_id']!=115 && $filter['node_id']!=116 && $filter['node_id']!=141 )$filter['node_id']=100;
						
			$aInfo = $objSitemap->getpathbyid( $filter['node_id'], false );
			foreach ( $aInfo as $r )
			{
				if ( !( $r['node_id'] == $filter['node_id'] ) )
				{
					continue;
				}
				$this->pagedata['cat_name'] = $r['title'];
				break;
			}
		}
		$filter['ifpub'] = 1;
		if ( $this->system->getconf( "system.seo.noindex_catalog" ) )
		{
			$this->header .= "<meta name=\"robots\" content=\"noindex,noarchive,follow\" />";
		}
		$pageLimit = 12;
		$objArticle = $this->system->loadmodel( "content/article" );
		$this->pagedata['articles'] = $objArticle->getlist( "title,article_id,pubtime,ifevent,limit_level", $filter, ( $page - 1 ) * $pageLimit, $pageLimit, $count );
		
		$this->pagedata['pager'] = array(
			"current" => $page,
			"total" => floor( $count / $pageLimit ) + 1,
			"link" => $this->system->mkurl( "artlist", "index", array(
				$cat_id,
				$tmp = time( )
			) ),
			"token" => $tmp
		);
		
		if ( $this->pagedata['pager']['total'] < $page )
		{
			$this->system->error( 404 );
		}
		if($GLOBALS['runtime']['member_lv'] >= 4)$this->pagedata['ifwhosales'] = 1;
		else $this->pagedata['ifwhosales'] = 0;
		$this->path[] = array( "title" => "" );
		$this->title = $this->pagedata['cat_name'];
		$this->pagedata['cat_id'] = $cat_id;
		$this->output( );
	}
	
	

}

?>